package com.camel;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class CamelOnCompletionTest {
	
	public static void main(String[] args)throws Exception {
		ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext("camel/context.xml");
		
		CamelContext context = appContext.getBean(CamelContext.class);
		
		for(int i = 0 ; i < 10; i++) {
			Exchange exchange1 = new DefaultExchange(context);
			exchange1.setProperty("id", i);
			exchange1.getIn().setBody("Input" + i);
			context.createProducerTemplate().send("direct:input1", exchange1);
			
			Thread.sleep(10000);
			
			Exchange exchange2 = new DefaultExchange(context);
			exchange2.setProperty("id", i);
			exchange2.getIn().setBody("Input" + i);
			context.createProducerTemplate().send("direct:input2", exchange2);
		}
		
		/*Exchange exchange3 = new DefaultExchange(context);
		exchange3.getIn().setBody("Input3,Input4");
		context.createProducerTemplate().send("direct:input3", exchange3);*/
		
		Thread.sleep(100000);
		appContext.close();
	}

}
